<template>
  <div class="mobile-skeleton-container">
    <!-- 页面标题骨架 -->
    <div class="skeleton-header" v-if="showHeader">
      <div class="skeleton-back-btn"></div>
      <div class="skeleton-title"></div>
      <div class="skeleton-action"></div>
    </div>
    
    <!-- 搜索表单骨架 -->
    <div class="skeleton-search-form" v-if="showSearch">
      <div class="skeleton-form-item" v-for="i in searchFields" :key="`search-${i}`"></div>
      <div class="skeleton-button-group">
        <div class="skeleton-button"></div>
        <div class="skeleton-button"></div>
      </div>
    </div>
    
    <!-- 卡片列表骨架 -->
    <div class="skeleton-card-list" v-if="showCards">
      <div class="skeleton-card" v-for="i in cardsCount" :key="`card-${i}`">
        <div class="skeleton-card-header">
          <div class="skeleton-card-title"></div>
        </div>
        <div class="skeleton-card-content">
          <div class="skeleton-info-item" v-for="j in 4" :key="`info-${i}-${j}`">
            <div class="skeleton-label"></div>
            <div class="skeleton-value"></div>
          </div>
        </div>
        <div class="skeleton-card-footer">
          <div class="skeleton-action-btn"></div>
          <div class="skeleton-action-btn"></div>
        </div>
      </div>
    </div>
    
    <!-- 表格骨架 -->
    <div class="skeleton-table" v-if="showTable">
      <div class="skeleton-table-header">
        <div class="skeleton-th" v-for="i in tableColumns" :key="`th-${i}`"></div>
      </div>
      <div class="skeleton-table-body">
        <div class="skeleton-tr" v-for="i in tableRows" :key="`tr-${i}`">
          <div class="skeleton-td" v-for="j in tableColumns" :key="`td-${i}-${j}`"></div>
        </div>
      </div>
    </div>
    
    <!-- 表单骨架 -->
    <div class="skeleton-form" v-if="showForm">
      <div class="skeleton-form-group" v-for="i in formFields" :key="`form-${i}`">
        <div class="skeleton-form-label"></div>
        <div class="skeleton-form-input"></div>
      </div>
      <div class="skeleton-form-buttons">
        <div class="skeleton-button"></div>
      </div>
    </div>
    
    <!-- 分页骨架 -->
    <div class="skeleton-pagination" v-if="showPagination">
      <div class="skeleton-pagination-info"></div>
      <div class="skeleton-pagination-buttons"></div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'MobileSkeleton',
  props: {
    showHeader: {
      type: Boolean,
      default: true
    },
    showSearch: {
      type: Boolean,
      default: false
    },
    searchFields: {
      type: Number,
      default: 2
    },
    showCards: {
      type: Boolean,
      default: true
    },
    cardsCount: {
      type: Number,
      default: 3
    },
    showTable: {
      type: Boolean,
      default: false
    },
    tableColumns: {
      type: Number,
      default: 4
    },
    tableRows: {
      type: Number,
      default: 5
    },
    showForm: {
      type: Boolean,
      default: false
    },
    formFields: {
      type: Number,
      default: 4
    },
    showPagination: {
      type: Boolean,
      default: true
    }
  }
}
</script>

<style lang="scss" scoped>
.mobile-skeleton-container {
  padding: 10px;
  
  @keyframes shimmer {
    0% {
      background-position: -468px 0;
    }
    100% {
      background-position: 468px 0;
    }
  }
  
  .shimmer-bg {
    background: #f6f7f8;
    background-image: linear-gradient(to right, #f6f7f8 0%, #edeef1 20%, #f6f7f8 40%, #f6f7f8 100%);
    background-repeat: no-repeat;
    background-size: 800px 104px;
    animation-duration: 1.5s;
    animation-fill-mode: forwards;
    animation-iteration-count: infinite;
    animation-name: shimmer;
    animation-timing-function: linear;
  }
  
  .skeleton-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 50px;
    margin-bottom: 15px;
    
    .skeleton-back-btn {
      width: 32px;
      height: 32px;
      border-radius: 50%;
      @extend .shimmer-bg;
    }
    
    .skeleton-title {
      width: 150px;
      height: 24px;
      border-radius: 4px;
      @extend .shimmer-bg;
    }
    
    .skeleton-action {
      width: 32px;
      height: 32px;
      border-radius: 4px;
      @extend .shimmer-bg;
    }
  }
  
  .skeleton-search-form {
    margin-bottom: 20px;
    
    .skeleton-form-item {
      height: 42px;
      border-radius: 4px;
      margin-bottom: 15px;
      @extend .shimmer-bg;
    }
    
    .skeleton-button-group {
      display: flex;
      justify-content: space-between;
      
      .skeleton-button {
        width: 48%;
        height: 36px;
        border-radius: 4px;
        @extend .shimmer-bg;
      }
    }
  }
  
  .skeleton-card-list {
    .skeleton-card {
      margin-bottom: 15px;
      padding: 15px;
      border-radius: 8px;
      background-color: #fff;
      box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
      
      .skeleton-card-header {
        margin-bottom: 15px;
        
        .skeleton-card-title {
          width: 70%;
          height: 24px;
          border-radius: 4px;
          @extend .shimmer-bg;
        }
      }
      
      .skeleton-card-content {
        .skeleton-info-item {
          display: flex;
          margin-bottom: 10px;
          
          .skeleton-label {
            width: 80px;
            height: 16px;
            margin-right: 10px;
            border-radius: 4px;
            @extend .shimmer-bg;
          }
          
          .skeleton-value {
            flex: 1;
            height: 16px;
            border-radius: 4px;
            @extend .shimmer-bg;
          }
        }
      }
      
      .skeleton-card-footer {
        display: flex;
        justify-content: space-between;
        margin-top: 15px;
        padding-top: 10px;
        border-top: 1px solid #ebeef5;
        
        .skeleton-action-btn {
          width: 80px;
          height: 32px;
          border-radius: 4px;
          @extend .shimmer-bg;
        }
      }
    }
  }
  
  .skeleton-table {
    margin-bottom: 20px;
    
    .skeleton-table-header {
      display: flex;
      height: 40px;
      margin-bottom: 10px;
      
      .skeleton-th {
        flex: 1;
        height: 100%;
        margin-right: 10px;
        border-radius: 4px;
        @extend .shimmer-bg;
        
        &:last-child {
          margin-right: 0;
        }
      }
    }
    
    .skeleton-table-body {
      .skeleton-tr {
        display: flex;
        height: 40px;
        margin-bottom: 10px;
        
        .skeleton-td {
          flex: 1;
          height: 100%;
          margin-right: 10px;
          border-radius: 4px;
          @extend .shimmer-bg;
          
          &:last-child {
            margin-right: 0;
          }
        }
      }
    }
  }
  
  .skeleton-form {
    .skeleton-form-group {
      margin-bottom: 20px;
      
      .skeleton-form-label {
        width: 100px;
        height: 16px;
        margin-bottom: 8px;
        border-radius: 4px;
        @extend .shimmer-bg;
      }
      
      .skeleton-form-input {
        width: 100%;
        height: 42px;
        border-radius: 4px;
        @extend .shimmer-bg;
      }
    }
    
    .skeleton-form-buttons {
      margin-top: 30px;
      
      .skeleton-button {
        width: 100%;
        height: 44px;
        border-radius: 4px;
        @extend .shimmer-bg;
      }
    }
  }
  
  .skeleton-pagination {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
    
    .skeleton-pagination-info {
      width: 150px;
      height: 20px;
      margin-bottom: 10px;
      border-radius: 4px;
      @extend .shimmer-bg;
    }
    
    .skeleton-pagination-buttons {
      width: 250px;
      height: 32px;
      border-radius: 4px;
      @extend .shimmer-bg;
    }
  }
}
</style> 